package com.inews.ui;

import weibo4android.http.AccessToken;

import com.inews.R;
import com.inews.bean.Task;
import com.inews.logic.MainService;
import com.inews.util.JavaScriptUtil;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class AccessTokenActivity extends Activity implements IWeiboActivity{
	
	private static final String TAG = "AccessTokenActivity";
	
	private TextView textView;
	
	private ProgressDialog progressDialog;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.at);
		textView = (TextView) this.findViewById(R.id.accessToken);
		
		Task task = new Task(Task.GET_ACCESS_TOKEN, null);
		MainService.newTask(task);
		MainService.addActivity(this);
		
		init();
	}

	@Override
	public void init() {
		Log.i("AccessTokenActivity获取的授权码", JavaScriptUtil.PIN);
		if(progressDialog == null){
			progressDialog = new ProgressDialog(this);
		}
		progressDialog.setMessage(getString(R.string.get_access_token_ing));
	}

	@Override
	public void refresh(Object... params) {
		progressDialog.dismiss();
		AccessToken accessToken = (AccessToken) params[0];
		Log.i(TAG, "get token>>>>>>" + accessToken.getUserId());
		//把accessToken保存进数据库
		
	}

}
